﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Feedback_Add.aspx.cs" Inherits="JKF.Web.Feedback.Feedback_Add" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
        <%=RegScript("~/js/jquery.1.5.js")%>
        <%=RegScript("~/js/Common.js")%>
        <%=RegScript("~/js/jquery.json.js")%>
        <%=RegScript("~/js/jquery.nhis.js")%>
        <%=RegScript("~/js/jquery.rchis.js")%>
        <%=RegScript("~/js/jquery.validate.js")%>
        <%=RegScript("~/js/DatePicker/WdatePicker.js")%>
        <%=RegStyle("~/js/suggest/jquery.suggest.css")%>
        <%=RegScript("~/js/jquery-ui-custom.min.js")%>
      <script src="../../js/Uppop/tipswindown2.js"  type="text/javascript"></script>
        
     <link href="../../App_Themes/Theme2/Include.css"   rel="stylesheet" type="text/css" />

    <script type="text/javascript" language="javascript">
        var isAdd = '<%=NoAddRedirect%>'  //没有权限跳转到提示页面
        $(function () {
            $("#BtnSave").click(function () {
                saveFeedback();
            })
        });    
    </script>

    <script type="text/javascript">
        var arrLinkBtn = new Array();
        arrLinkBtn.push(new Array('parent.tipsWindown.close()', '继续添加')); //调用函数的参数要用双引号
        arrLinkBtn.push(new Array('parent.tipsWindown.close()', '返回列表')); //调用函数的参数要用双引号


        var AppPath = "<%=AppPath %>";
        var handler = AppPath + '/do/Feedback/Feedback.do';
        var scid = '<%=P("feedbackKey") %>';
        var dateCreate = '<%=DateTime.Now.ToString("yyyy-MM-dd") %>'; //如果是添加则取当前日期 如果是修改则是数据创建时间
        var ntEmpt = /^[^ ]+$/;
        var dtReg = /^\d{4}(\/|-)([1][0-2]|[1-9]|0[1-9])(\/|-)([1-2][0-9]|3[0-1]|[1-9]|0[1-9])( (0?[0-9]|1[0-9]|2[0-4])(:([0-5][0-9])){1,2})?$/;

        $(function () {
            if (scid == "") {
                $("#FEEDBACK_DATE").val(dateCreate);
            }
            check();

            $('#btnclose').click(function () {
                parent.tipsWindown.close();
            });
        });

        function check() {
            alxVr.push({ id: "TITLE",
                rule: function (jd) {
                    if (!ntEmpt.test(jd.val())) {
                        this.msg = "请填写咨询问题."; return false;
                    } else if ($.FxNull(jd.val(), "").length > 100) {
                        this.msg = "咨询问题应在100个字符之内."; return false;
                    } return true;
                }
            });

            alxVr.push({ id: "FEEDBACKER",
                rule: function (jd) {
                    if (!ntEmpt.test(jd.val())) {
                        this.msg = "请填写咨询人."; return false;
                    } else if ($.FxNull(jd.val(), "").length > 100) {
                        this.msg = "咨询人应在50个字符之内."; return false;
                    } return true;
                }
            });

            alxVr.push({ id: "FEEDBACK_DATE", rule: function (jd) {
                var val = $.trim(jd.val());
                if (!dtReg.test(val)) {
                    this.msg = "咨询日期格式不正确，应为日期(如2011-1-1).";
                    return false;
                }
                return true;
              }
        });

        alxVr.push({ id: "CONTENT",
            rule: function (jd) {
                //alert(jd.val());

                //if (!ntEmpt.test(jd.val())) {
                if (jd.val()=="") {
                    this.msg = "请填写咨询内容."; return false;
                } else if ($.FxNull(jd.val(), "").length > 1000) {
                    this.msg = "咨询内容在1000个字符之内."; return false;
                } return true;
 
            }
        });

            $.validateBind();
        }

        function saveFeedback() {
            if (!$.validateAll()) {
                if ($(".alxv-failed").size() > 0) {
                    $(document).scrollTop($(".alxv-failed").eq(0).scrollTop());
                }
                return;
            };

            var tObj = {}, objCfg = {}, pName;
            $(":text,input:checked,select,textarea,hidden").each(function () {
                pName = ($.FxNull($(this).attr("type"), "").toLowerCase() == "radio") ? $.FxNull($(this).attr("name"), "").toUpperCase() : $.FxNull($(this).attr("id"), "").toUpperCase();

                tObj[pName] = (objCfg[pName]) ? $.FxNull($(this).attr(objCfg[pName]), "") : $(this).val();
            });

            tObj.FILE_PATH = $("#FILE_PATH").val();
            tObj.TYPE ="0";
           

            if ($.FxNull(scid, "").length > 10) {//主键
                tObj.FEEDBACK_KEY = scid;
            }
            else {
                tObj.FEEDBACK_KEY = "";
            }

            $.post(handler, { ActionName: "EditOrInsertFeedback", feedbackObj: $.toJSON(tObj) }, function (rslt) {
                if (rslt.MessageCode == "Ok") {//保存成功
                    if (scid == "") {
                        scid = rslt.Data; //记录主键
                        if (typeof (eval(window.parent.callBackFun)) == "function") {
                            //alert(typeof (eval(window.parent.callBackFun)));
                            updateView(""); //添加或修改数据成功后更新列表页面
                        }

                    }
                    else {
                        if (typeof (eval(window.parent.callBackFun)) == "function") {
                            updateView(scid);
                        }
                    }

                    $.popResultTip('操作成功', arrLinkBtn)
                    return;
                }
                //alert(rslt.Message);
            }, "json");
        }

        function updateView(pk) {
            tr = $("<tr key=" + scid + "></tr>");
            var btns
            btns = '<input  class="btn_style" value="查看详细" type="button"   onclick="viewFeedback(' + "'" + scid + "'" + ')">';
            btns += "<input    style=\"display:' + isDelete + '\" id=\"btnDel\" type=\"button\" class=\"common_btn_del mr12\"  onclick=\"delFeedback('" + scid + "')\">";
            btns += '<input  class="btn_style" id="btnReply" value="回复" type="button"   onclick="replyFeedback(' + "'" + scid + "'" + ')">';
            $('<td></td>').appendTo(tr).html(btns);
            $('<td></td>').appendTo(tr).html($("#TITLE").val());
            $('<td></td>').appendTo(tr).text($("#FEEDBACKER").val());
            $('<td></td>').appendTo(tr).text($("#FEEDBACK_DATE").val());
            $('<td></td>').appendTo(tr).text("未回复");

            window.parent.popRetuInfo($(tr),pk)
        }  
    </script>
</head>
<body >
   <form id="form1" runat="server">
    <div class="pop_logging_body" style="padding:22px 70px; margin-top:0px; margin-bottom:26px; margin-right:35px; margin-left:35px ">
           <table width="100%" border="0" cellspacing="0" cellpadding="0"   class="common_table_noborde">
              <tr >
                 <td><span class="fred">*</span>咨询问题</td>
                 <td colspan="3">
                     <input runat="server" id="TITLE" type="text" style="width:550px" />
                 </td>
              </tr>
               <tr>
                 <td><span class="fred">*</span>咨询人</td>
                 <td>
                    <input runat="server" id="FEEDBACKER" type="text" />
                 </td>
                 <td><span class="fred">*</span>咨询日期</td>
                 <td>
                    <input  id="FEEDBACK_DATE" type="text" onfocus="WdatePicker()"/>
                 </td>                
              </tr>
               <tr>
                 <td>图片</td>
                 <td colspan="3"> 
                     <asp:FileUpload ID="FileUpload1" runat="server" />
                     <asp:Button ID="BtnUpload" runat="server" Text="上传" 
                         onclick="BtnUpload_Click" />
                         <br />
                     <asp:Label ID="LblFile_path" runat="server" Text=""></asp:Label>
                     <asp:HiddenField ID="FILE_PATH" runat="server" />
                 </td>
              </tr>
               <tr>
                 <td ><span class="fred">*</span>咨询内容</td>
                 <td colspan="3" style=" height:200px;">
                  
                   <!--<input type="text" id="CONTENT"  style="width:550px; height:250px;" />-->
                  <textarea id="CONTENT" rows="10" cols="20" style="width:550px; height:250px;" ></textarea>
                 </td>
               </tr>
          </table>
     </div>
     <div class="pop_btn">
         <input id="BtnSave" type="button" class="common_btn_save mr30 mb25" value="" />
	     <input id="btnclose" type="button" class="common_btn_remove mb25" value=" "  />
     </div>
   </form>
</body>
</html>
